home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2001 May / SGI Freeware 2001 May - Disc 3.iso / dist / fw_apache.idb / usr / freeware / apache / include / httpd.h.z / httpd.h
C/C++ Source or Header  |  2001-01-10  |  46KB  |  1,257 lines

  1. /* ====================================================================
  2.  * Copyright (c) 1995-1999 The Apache Group.  All rights reserved.
  3.  *
  4.  * Redistribution and use in source and binary forms, with or without
  5.  * modification, are permitted provided that the following conditions
  6.  * are met:
  7.  *
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer. 
  10.  *
  11.  * 2. Redistributions in binary form must reproduce the above copyright
  12.  *    notice, this list of conditions and the following disclaimer in
  13.  *    the documentation and/or other materials provided with the
  14.  *    distribution.
  15.  *
  16.  * 3. All advertising materials mentioning features or use of this
  17.  *    software must display the following acknowledgment:
  18.  *    "This product includes software developed by the Apache Group
  19.  *    for use in the Apache HTTP server project (http://www.apache.org/)."
  20.  *
  21.  * 4. The names "Apache Server" and "Apache Group" must not be used to
  22.  *    endorse or promote products derived from this software without
  23.  *    prior written permission. For written permission, please contact
  24.  *    apache@apache.org.
  25.  *
  26.  * 5. Products derived from this software may not be called "Apache"
  27.  *    nor may "Apache" appear in their names without prior written
  28.  *    permission of the Apache Group.
  29.  *
  30.  * 6. Redistributions of any form whatsoever must retain the following
  31.  *    acknowledgment:
  32.  *    "This product includes software developed by the Apache Group
  33.  *    for use in the Apache HTTP server project (http://www.apache.org/)."
  34.  *
  35.  * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
  36.  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  37.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  38.  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE APACHE GROUP OR
  39.  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  41.  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  42.  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  43.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  44.  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  45.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  46.  * OF THE POSSIBILITY OF SUCH DAMAGE.
  47.  * ====================================================================
  48.  *
  49.  * This software consists of voluntary contributions made by many
  50.  * individuals on behalf of the Apache Group and was originally based
  51.  * on public domain software written at the National Center for
  52.  * Supercomputing Applications, University of Illinois, Urbana-Champaign.
  53.  * For more information on the Apache Group and the Apache HTTP server
  54.  * project, please see <http://www.apache.org/>.
  55.  *
  56.  */
  57.  
  58. #ifndef APACHE_HTTPD_H
  59. #define APACHE_HTTPD_H
  60.  
  61. #ifdef __cplusplus
  62. extern "C" {
  63. #endif
  64.  
  65. /*
  66.  * httpd.h: header for simple (ha! not anymore) http daemon
  67.  */
  68.  
  69. /* Headers in which EVERYONE has an interest... */
  70.  
  71. #include "ap_config.h"
  72. #ifdef EAPI
  73. #include "ap_mm.h"
  74. #endif
  75. #include "ap_alloc.h"
  76. /*
  77.  * Include the Extended API headers.
  78.  * Don't move the position. It has to be after ap_alloc.h because it uses the
  79.  * pool stuff but before buff.h because the buffer stuff uses the EAPI, too. 
  80.  */
  81. #ifdef EAPI
  82. #include "ap_hook.h"
  83. #include "ap_ctx.h"
  84. #endif /* EAPI */
  85. #include "buff.h"
  86. #include "ap.h"
  87.  
  88. /* ----------------------------- config dir ------------------------------ */
  89.  
  90. /* Define this to be the default server home dir. Most things later in this
  91.  * file with a relative pathname will have this added.
  92.  */
  93. #ifndef HTTPD_ROOT
  94. #ifdef OS2
  95. /* Set default for OS/2 file system */
  96. #define HTTPD_ROOT "/os2httpd"
  97. #elif defined(WIN32)
  98. /* Set default for Windows file system */
  99. #define HTTPD_ROOT "/apache"
  100. #elif defined(BEOS)
  101. #define HTTPD_ROOT "/boot/home/apache"
  102. #elif defined(NETWARE)
  103. #define HTTPD_ROOT "sys:/apache"
  104. #else
  105. #define HTTPD_ROOT "/usr/local/apache"
  106. #endif
  107. #endif /* HTTPD_ROOT */
  108.  
  109. /* Default location of documents.  Can be overridden by the DocumentRoot
  110.  * directive.
  111.  */
  112. #ifndef DOCUMENT_LOCATION
  113. #ifdef OS2
  114. /* Set default for OS/2 file system */
  115. #define DOCUMENT_LOCATION  HTTPD_ROOT "/docs"
  116. #else
  117. #define DOCUMENT_LOCATION  HTTPD_ROOT "/htdocs"
  118. #endif
  119. #endif /* DOCUMENT_LOCATION */
  120.  
  121. /* Max. number of dynamically loaded modules */
  122. #ifndef DYNAMIC_MODULE_LIMIT
  123. #define DYNAMIC_MODULE_LIMIT 64
  124. #endif
  125.  
  126. /* Default administrator's address */
  127. #define DEFAULT_ADMIN "[no address given]"
  128.  
  129. /* The target name of the installed Apache */
  130. #ifndef TARGET
  131. #define TARGET "httpd"
  132. #endif
  133.  
  134. /* 
  135.  * --------- You shouldn't have to edit anything below this line ----------
  136.  *
  137.  * Any modifications to any defaults not defined above should be done in the 
  138.  * respective config. file. 
  139.  *
  140.  */
  141.  
  142.  
  143. /* -- Internal representation for a HTTP protocol number, e.g., HTTP/1.1 -- */
  144.  
  145. #define HTTP_VERSION(major,minor) (1000*(major)+(minor))
  146. #define HTTP_VERSION_MAJOR(number) ((number)/1000)
  147. #define HTTP_VERSION_MINOR(number) ((number)%1000)
  148.  
  149.  
  150. /* -------------- Port number for server running standalone --------------- */
  151.  
  152. #define DEFAULT_HTTP_PORT    80
  153. #define DEFAULT_HTTPS_PORT    443
  154. #define ap_is_default_port(port,r)    ((port) == ap_default_port(r))
  155. #ifdef EAPI
  156. #define ap_http_method(r)   (ap_ctx_get((r)->ctx, "ap::http::method") != NULL ? ((char *)ap_ctx_get((r)->ctx, "ap::http::method")) : "http")
  157. #define ap_default_port(r)  (ap_ctx_get((r)->ctx, "ap::default::port") != NULL ? atoi((char *)ap_ctx_get((r)->ctx, "ap::default::port")) : DEFAULT_HTTP_PORT)
  158. #else /* EAPI */
  159. #define ap_http_method(r)    "http"
  160. #define ap_default_port(r)    DEFAULT_HTTP_PORT
  161. #endif /* EAPI */
  162.  
  163. /* --------- Default user name and group name running standalone ---------- */
  164. /* --- These may be specified as numbers by placing a # before a number --- */
  165.  
  166. #ifndef DEFAULT_USER
  167. #define DEFAULT_USER "#-1"
  168. #endif
  169. #ifndef DEFAULT_GROUP
  170. #define DEFAULT_GROUP "#-1"
  171. #endif
  172.  
  173. /* The name of the log files */
  174. #ifndef DEFAULT_XFERLOG
  175. #if defined(OS2) || defined(WIN32)
  176. #define DEFAULT_XFERLOG "logs/access.log"
  177. #else
  178. #define DEFAULT_XFERLOG "logs/access_log"
  179. #endif
  180. #endif /* DEFAULT_XFERLOG */
  181.  
  182. #ifndef DEFAULT_ERRORLOG
  183. #if defined(OS2) || defined(WIN32)
  184. #define DEFAULT_ERRORLOG "logs/error.log"
  185. #else
  186. #define DEFAULT_ERRORLOG "logs/error_log"
  187. #endif
  188. #endif /* DEFAULT_ERRORLOG */
  189.  
  190. #ifndef DEFAULT_PIDLOG
  191. #define DEFAULT_PIDLOG "logs/httpd.pid"
  192. #endif
  193. #ifndef DEFAULT_SCOREBOARD
  194. #define DEFAULT_SCOREBOARD "logs/apache_runtime_status"
  195. #endif
  196. #ifndef DEFAULT_LOCKFILE
  197. #define DEFAULT_LOCKFILE "logs/accept.lock"
  198. #endif
  199.  
  200. /* Define this to be what your HTML directory content files are called */
  201. #ifndef DEFAULT_INDEX
  202. #define DEFAULT_INDEX "index.html"
  203. #endif
  204.  
  205. /* Define this to 1 if you want fancy indexing, 0 otherwise */
  206. #ifndef DEFAULT_INDEXING
  207. #define DEFAULT_INDEXING 0
  208. #endif
  209.  
  210. /* Define this to be what type you'd like returned for files with unknown */
  211. /* suffixes.  MUST be all lower case. */
  212. #ifndef DEFAULT_CONTENT_TYPE
  213. #define DEFAULT_CONTENT_TYPE "text/plain"
  214. #endif
  215.  
  216. /* Define this to be what your per-directory security files are called */
  217. #ifndef DEFAULT_ACCESS_FNAME
  218. #ifdef OS2
  219. /* Set default for OS/2 file system */
  220. #define DEFAULT_ACCESS_FNAME "htaccess"
  221. #else
  222. #define DEFAULT_ACCESS_FNAME ".htaccess"
  223. #endif
  224. #endif /* DEFAULT_ACCESS_FNAME */
  225.  
  226. /* The name of the server config file */
  227. #ifndef SERVER_CONFIG_FILE
  228. #define SERVER_CONFIG_FILE "conf/httpd.conf"
  229. #endif
  230.  
  231. /* The name of the document config file */
  232. #ifndef RESOURCE_CONFIG_FILE
  233. #define RESOURCE_CONFIG_FILE "conf/srm.conf"
  234. #endif
  235.  
  236. /* The name of the MIME types file */
  237. #ifndef TYPES_CONFIG_FILE
  238. #define TYPES_CONFIG_FILE "conf/mime.types"
  239. #endif
  240.  
  241. /* The name of the access file */
  242. #ifndef ACCESS_CONFIG_FILE
  243. #define ACCESS_CONFIG_FILE "conf/access.conf"
  244. #endif
  245.  
  246. /* Whether we should enable rfc1413 identity checking */
  247. #ifndef DEFAULT_RFC1413
  248. #define DEFAULT_RFC1413 0
  249. #endif
  250. /* The default directory in user's home dir */
  251. #ifndef DEFAULT_USER_DIR
  252. #define DEFAULT_USER_DIR "public_html"
  253. #endif
  254.  
  255. /* The default path for CGI scripts if none is currently set */
  256. #ifndef DEFAULT_PATH
  257. #define DEFAULT_PATH "/bin:/usr/bin:/usr/ucb:/usr/bsd:/usr/local/bin"
  258. #endif
  259.  
  260. /* The path to the shell interpreter, for parsed docs */
  261. #ifndef SHELL_PATH
  262. #if defined(OS2) || defined(WIN32)
  263. /* Set default for OS/2 and Windows file system */
  264. #define SHELL_PATH "CMD.EXE"
  265. #else
  266. #define SHELL_PATH "/bin/sh"
  267. #endif
  268. #endif /* SHELL_PATH */
  269.  
  270. /* The path to the suExec wrapper, can be overridden in Configuration */
  271. #ifndef SUEXEC_BIN
  272. #define SUEXEC_BIN  HTTPD_ROOT "/bin/suexec"
  273. #endif
  274.  
  275. /* The default string lengths */
  276. #define MAX_STRING_LEN HUGE_STRING_LEN
  277. #define HUGE_STRING_LEN 8192
  278.  
  279. /* The timeout for waiting for messages */
  280. #ifndef DEFAULT_TIMEOUT
  281. #define DEFAULT_TIMEOUT 300
  282. #endif
  283.  
  284. /* The timeout for waiting for keepalive timeout until next request */
  285. #ifndef DEFAULT_KEEPALIVE_TIMEOUT
  286. #define DEFAULT_KEEPALIVE_TIMEOUT 15
  287. #endif
  288.  
  289. /* The number of requests to entertain per connection */
  290. #ifndef DEFAULT_KEEPALIVE
  291. #define DEFAULT_KEEPALIVE 100
  292. #endif
  293.  
  294. /* The size of the server's internal read-write buffers */
  295. #define IOBUFSIZE 8192
  296.  
  297. /* Number of servers to spawn off by default --- also, if fewer than
  298.  * this free when the caretaker checks, it will spawn more.
  299.  */
  300. #ifndef DEFAULT_START_DAEMON
  301. #define DEFAULT_START_DAEMON 5
  302. #endif
  303.  
  304. /* Maximum number of *free* server processes --- more than this, and
  305.  * they will die off.
  306.  */
  307.  
  308. #ifndef DEFAULT_MAX_FREE_DAEMON
  309. #define DEFAULT_MAX_FREE_DAEMON 10
  310. #endif
  311.  
  312. /* Minimum --- fewer than this, and more will be created */
  313.  
  314. #ifndef DEFAULT_MIN_FREE_DAEMON
  315. #define DEFAULT_MIN_FREE_DAEMON 5
  316. #endif
  317.  
  318. /* Limit on the total --- clients will be locked out if more servers than
  319.  * this are needed.  It is intended solely to keep the server from crashing
  320.  * when things get out of hand.
  321.  *
  322.  * We keep a hard maximum number of servers, for two reasons --- first off,
  323.  * in case something goes seriously wrong, we want to stop the fork bomb
  324.  * short of actually crashing the machine we're running on by filling some
  325.  * kernel table.  Secondly, it keeps the size of the scoreboard file small
  326.  * enough that we can read the whole thing without worrying too much about
  327.  * the overhead.
  328.  */
  329. #ifndef HARD_SERVER_LIMIT
  330. #ifdef WIN32
  331. #define HARD_SERVER_LIMIT 1024
  332. #else
  333. #define HARD_SERVER_LIMIT 256
  334. #endif
  335. #endif
  336.  
  337. /*
  338.  * Special Apache error codes. These are basically used
  339.  *  in http_main.c so we can keep track of various errors.
  340.  *
  341.  *   APEXIT_OK:
  342.  *     A normal exit
  343.  *   APEXIT_INIT:
  344.  *     A fatal error arising during the server's init sequence
  345.  *   APEXIT_CHILDINIT:
  346.  *     The child died during it's init sequence
  347.  *   APEXIT_CHILDFATAL:
  348.  *     A fatal error, resulting in the whole server aborting.
  349.  *     If a child exits with this error, the parent process
  350.  *     considers this a server-wide fatal error and aborts.
  351.  *                 
  352.  */
  353. #define APEXIT_OK        0x0
  354. #define APEXIT_INIT        0x2
  355. #define APEXIT_CHILDINIT    0x3
  356. #define APEXIT_CHILDFATAL    0xf
  357.  
  358. /*
  359.  * (Unix, OS/2 only)
  360.  * Interval, in microseconds, between scoreboard maintenance.  During
  361.  * each scoreboard maintenance cycle the parent decides if it needs to
  362.  * spawn a new child (to meet MinSpareServers requirements), or kill off
  363.  * a child (to meet MaxSpareServers requirements).  It will only spawn or
  364.  * kill one child per cycle.  Setting this too low will chew cpu.  The
  365.  * default is probably sufficient for everyone.  But some people may want
  366.  * to raise this on servers which aren't dedicated to httpd and where they
  367.  * don't like the httpd waking up each second to see what's going on.
  368.  */
  369. #ifndef SCOREBOARD_MAINTENANCE_INTERVAL
  370. #define SCOREBOARD_MAINTENANCE_INTERVAL 1000000
  371. #endif
  372.  
  373. /*
  374.  * Unix only:
  375.  * Path to Shared Memory Files 
  376.  */
  377. #ifdef EAPI
  378. #ifndef EAPI_MM_CORE_PATH
  379. #define EAPI_MM_CORE_PATH "logs/mm"
  380. #endif
  381. #ifndef EAPI_MM_CORE_MAXSIZE
  382. #define EAPI_MM_CORE_MAXSIZE 1024*1024*1 /* max. 1MB */
  383. #endif
  384. #endif
  385.  
  386. /* Number of requests to try to handle in a single process.  If <= 0,
  387.  * the children don't die off.  That's the default here, since I'm still
  388.  * interested in finding and stanching leaks.
  389.  */
  390.  
  391. #ifndef DEFAULT_MAX_REQUESTS_PER_CHILD
  392. #define DEFAULT_MAX_REQUESTS_PER_CHILD 0
  393. #endif
  394.  
  395. #ifndef DEFAULT_THREADS_PER_CHILD
  396. #define DEFAULT_THREADS_PER_CHILD 50
  397. #endif
  398. #ifndef DEFAULT_EXCESS_REQUESTS_PER_CHILD
  399. #define DEFAULT_EXCESS_REQUESTS_PER_CHILD 0
  400. #endif
  401.  
  402. /* The maximum length of the queue of pending connections, as defined
  403.  * by listen(2).  Under some systems, it should be increased if you
  404.  * are experiencing a heavy TCP SYN flood attack.
  405.  *
  406.  * It defaults to 511 instead of 512 because some systems store it 
  407.  * as an 8-bit datatype; 512 truncated to 8-bits is 0, while 511 is 
  408.  * 255 when truncated.
  409.  */
  410.  
  411. #ifndef DEFAULT_LISTENBACKLOG
  412. #define DEFAULT_LISTENBACKLOG 511
  413. #endif
  414.  
  415. /* Limits on the size of various request items.  These limits primarily
  416.  * exist to prevent simple denial-of-service attacks on a server based
  417.  * on misuse of the protocol.  The recommended values will depend on the
  418.  * nature of the server resources -- CGI scripts and database backends
  419.  * might require large values, but most servers could get by with much
  420.  * smaller limits than we use below.  The request message body size can
  421.  * be limited by the per-dir config directive LimitRequestBody.
  422.  *
  423.  * Internal buffer sizes are two bytes more than the DEFAULT_LIMIT_REQUEST_LINE
  424.  * and DEFAULT_LIMIT_REQUEST_FIELDSIZE below, which explains the 8190.
  425.  * These two limits can be lowered (but not raised) by the server config
  426.  * directives LimitRequestLine and LimitRequestFieldsize, respectively.
  427.  *
  428.  * DEFAULT_LIMIT_REQUEST_FIELDS can be modified or disabled (set = 0) by
  429.  * the server config directive LimitRequestFields.
  430.  */
  431. #ifndef DEFAULT_LIMIT_REQUEST_LINE
  432. #define DEFAULT_LIMIT_REQUEST_LINE 8190
  433. #endif /* default limit on bytes in Request-Line (Method+URI+HTTP-version) */
  434. #ifndef DEFAULT_LIMIT_REQUEST_FIELDSIZE
  435. #define DEFAULT_LIMIT_REQUEST_FIELDSIZE 8190
  436. #endif /* default limit on bytes in any one header field  */
  437. #ifndef DEFAULT_LIMIT_REQUEST_FIELDS
  438. #define DEFAULT_LIMIT_REQUEST_FIELDS 100
  439. #endif /* default limit on number of request header fields */
  440.  
  441. /*
  442.  * The default default character set name to add if AddDefaultCharset is 
  443.  * enabled.  Overridden with AddDefaultCharsetName.
  444.  */
  445. #define DEFAULT_ADD_DEFAULT_CHARSET_NAME "iso-8859-1"
  446.  
  447. /*
  448.  * The below defines the base string of the Server: header. Additional
  449.  * tokens can be added via the ap_add_version_component() API call.
  450.  *
  451.  * The tokens are listed in order of their significance for identifying the
  452.  * application.
  453.  *
  454.  * "Product tokens should be short and to the point -- use of them for 
  455.  * advertizing or other non-essential information is explicitly forbidden."
  456.  *
  457.  * Example: "Apache/1.1.0 MrWidget/0.1-alpha" 
  458.  */
  459.  
  460. #define SERVER_BASEVENDOR   "Apache Group"
  461. #define SERVER_BASEPRODUCT  "Apache"
  462. #define SERVER_BASEREVISION "1.3.14"
  463. #define SERVER_BASEVERSION  SERVER_BASEPRODUCT "/" SERVER_BASEREVISION
  464.  
  465. #define SERVER_PRODUCT  SERVER_BASEPRODUCT
  466. #define SERVER_REVISION SERVER_BASEREVISION
  467. #define SERVER_VERSION  SERVER_PRODUCT "/" SERVER_REVISION
  468. enum server_token_type {
  469.     SrvTk_MIN,        /* eg: Apache/1.3.0 */
  470.     SrvTk_OS,        /* eg: Apache/1.3.0 (UNIX) */
  471.     SrvTk_FULL,        /* eg: Apache/1.3.0 (UNIX) PHP/3.0 FooBar/1.2b */
  472.     SrvTk_PRODUCT_ONLY    /* eg: Apache */
  473. };
  474.  
  475. API_EXPORT(const char *) ap_get_server_version(void);
  476. API_EXPORT(void) ap_add_version_component(const char *component);
  477. API_EXPORT(const char *) ap_get_server_built(void);
  478. #ifdef EAPI
  479. API_EXPORT(void) ap_add_config_define(const char *define);
  480. #endif /* EAPI */
  481.  
  482. /* Numeric release version identifier: MMNNFFRBB: major minor fix final beta
  483.  * Always increases along the same track as the source branch.
  484.  * For example, Apache 1.4.2 would be '10402100', 2.5b7 would be '20500007'.
  485.  */
  486. #define APACHE_RELEASE 10314100
  487.  
  488. #define SERVER_PROTOCOL "HTTP/1.1"
  489. #ifndef SERVER_SUPPORT
  490. #define SERVER_SUPPORT "http://www.apache.org/"
  491. #endif
  492.  
  493. #define DECLINED -1        /* Module declines to handle */
  494. #define DONE -2            /* Module has served the response completely 
  495.                  *  - it's safe to die() with no more output
  496.                  */
  497. #define OK 0            /* Module has handled this stage. */
  498.  
  499.  
  500. /* ----------------------- HTTP Status Codes  ------------------------- */
  501.  
  502. /* The size of the static array in http_protocol.c for storing
  503.  * all of the potential response status-lines (a sparse table).
  504.  * A future version should dynamically generate the table at startup.
  505.  */
  506. #define RESPONSE_CODES 55
  507.  
  508. #define HTTP_CONTINUE                      100
  509. #define HTTP_SWITCHING_PROTOCOLS           101
  510. #define HTTP_PROCESSING                    102
  511. #define HTTP_OK                            200
  512. #define HTTP_CREATED                       201
  513. #define HTTP_ACCEPTED                      202
  514. #define HTTP_NON_AUTHORITATIVE             203
  515. #define HTTP_NO_CONTENT                    204
  516. #define HTTP_RESET_CONTENT                 205
  517. #define HTTP_PARTIAL_CONTENT               206
  518. #define HTTP_MULTI_STATUS                  207
  519. #define HTTP_MULTIPLE_CHOICES              300
  520. #define HTTP_MOVED_PERMANENTLY             301
  521. #define HTTP_MOVED_TEMPORARILY             302
  522. #define HTTP_SEE_OTHER                     303
  523. #define HTTP_NOT_MODIFIED                  304
  524. #define HTTP_USE_PROXY                     305
  525. #define HTTP_TEMPORARY_REDIRECT            307
  526. #define HTTP_BAD_REQUEST                   400
  527. #define HTTP_UNAUTHORIZED                  401
  528. #define HTTP_PAYMENT_REQUIRED              402
  529. #define HTTP_FORBIDDEN                     403
  530. #define HTTP_NOT_FOUND                     404
  531. #define HTTP_METHOD_NOT_ALLOWED            405
  532. #define HTTP_NOT_ACCEPTABLE                406
  533. #define HTTP_PROXY_AUTHENTICATION_REQUIRED 407
  534. #define HTTP_REQUEST_TIME_OUT              408
  535. #define HTTP_CONFLICT                      409
  536. #define HTTP_GONE                          410
  537. #define HTTP_LENGTH_REQUIRED               411
  538. #define HTTP_PRECONDITION_FAILED           412
  539. #define HTTP_REQUEST_ENTITY_TOO_LARGE      413
  540. #define HTTP_REQUEST_URI_TOO_LARGE         414
  541. #define HTTP_UNSUPPORTED_MEDIA_TYPE        415
  542. #define HTTP_RANGE_NOT_SATISFIABLE         416
  543. #define HTTP_EXPECTATION_FAILED            417
  544. #define HTTP_UNPROCESSABLE_ENTITY          422
  545. #define HTTP_LOCKED                        423
  546. #define HTTP_FAILED_DEPENDENCY             424
  547. #define HTTP_INTERNAL_SERVER_ERROR         500
  548. #define HTTP_NOT_IMPLEMENTED               501
  549. #define HTTP_BAD_GATEWAY                   502
  550. #define HTTP_SERVICE_UNAVAILABLE           503
  551. #define HTTP_GATEWAY_TIME_OUT              504
  552. #define HTTP_VERSION_NOT_SUPPORTED         505
  553. #define HTTP_VARIANT_ALSO_VARIES           506
  554. #define HTTP_INSUFFICIENT_STORAGE          507
  555. #define HTTP_NOT_EXTENDED                  510
  556.  
  557. #define DOCUMENT_FOLLOWS    HTTP_OK
  558. #define PARTIAL_CONTENT     HTTP_PARTIAL_CONTENT
  559. #define MULTIPLE_CHOICES    HTTP_MULTIPLE_CHOICES
  560. #define MOVED               HTTP_MOVED_PERMANENTLY
  561. #define REDIRECT            HTTP_MOVED_TEMPORARILY
  562. #define USE_LOCAL_COPY      HTTP_NOT_MODIFIED
  563. #define BAD_REQUEST         HTTP_BAD_REQUEST
  564. #define AUTH_REQUIRED       HTTP_UNAUTHORIZED
  565. #define FORBIDDEN           HTTP_FORBIDDEN
  566. #define NOT_FOUND           HTTP_NOT_FOUND
  567. #define METHOD_NOT_ALLOWED  HTTP_METHOD_NOT_ALLOWED
  568. #define NOT_ACCEPTABLE      HTTP_NOT_ACCEPTABLE
  569. #define LENGTH_REQUIRED     HTTP_LENGTH_REQUIRED
  570. #define PRECONDITION_FAILED HTTP_PRECONDITION_FAILED
  571. #define SERVER_ERROR        HTTP_INTERNAL_SERVER_ERROR
  572. #define NOT_IMPLEMENTED     HTTP_NOT_IMPLEMENTED
  573. #define BAD_GATEWAY         HTTP_BAD_GATEWAY
  574. #define VARIANT_ALSO_VARIES HTTP_VARIANT_ALSO_VARIES
  575.  
  576. #define ap_is_HTTP_INFO(x)         (((x) >= 100)&&((x) < 200))
  577. #define ap_is_HTTP_SUCCESS(x)      (((x) >= 200)&&((x) < 300))
  578. #define ap_is_HTTP_REDIRECT(x)     (((x) >= 300)&&((x) < 400))
  579. #define ap_is_HTTP_ERROR(x)        (((x) >= 400)&&((x) < 600))
  580. #define ap_is_HTTP_CLIENT_ERROR(x) (((x) >= 400)&&((x) < 500))
  581. #define ap_is_HTTP_SERVER_ERROR(x) (((x) >= 500)&&((x) < 600))
  582.  
  583. #define ap_status_drops_connection(x) \
  584.                                    (((x) == HTTP_BAD_REQUEST)           || \
  585.                                     ((x) == HTTP_REQUEST_TIME_OUT)      || \
  586.                                     ((x) == HTTP_LENGTH_REQUIRED)       || \
  587.                                     ((x) == HTTP_REQUEST_ENTITY_TOO_LARGE) || \
  588.                                     ((x) == HTTP_REQUEST_URI_TOO_LARGE) || \
  589.                                     ((x) == HTTP_INTERNAL_SERVER_ERROR) || \
  590.                                     ((x) == HTTP_SERVICE_UNAVAILABLE) || \
  591.                     ((x) == HTTP_NOT_IMPLEMENTED))
  592.  
  593. /* Methods recognized (but not necessarily handled) by the server.
  594.  * These constants are used in bit shifting masks of size int, so it is
  595.  * unsafe to have more methods than bits in an int.  HEAD == M_GET.
  596.  */
  597. #define M_GET        0
  598. #define M_PUT        1
  599. #define M_POST       2
  600. #define M_DELETE     3
  601. #define M_CONNECT    4
  602. #define M_OPTIONS    5
  603. #define M_TRACE      6
  604. #define M_PATCH      7
  605. #define M_PROPFIND   8
  606. #define M_PROPPATCH  9
  607. #define M_MKCOL     10
  608. #define M_COPY      11
  609. #define M_MOVE      12
  610. #define M_LOCK      13
  611. #define M_UNLOCK    14
  612. #define M_INVALID   15
  613.  
  614. #define METHODS     16
  615.  
  616. #define CGI_MAGIC_TYPE "application/x-httpd-cgi"
  617. #define INCLUDES_MAGIC_TYPE "text/x-server-parsed-html"
  618. #define INCLUDES_MAGIC_TYPE3 "text/x-server-parsed-html3"
  619. #ifdef CHARSET_EBCDIC
  620. #define ASCIITEXT_MAGIC_TYPE_PREFIX "text/x-ascii-" /* Text files whose content-type starts with this are passed thru unconverted */
  621. #endif /*CHARSET_EBCDIC*/
  622. #define MAP_FILE_MAGIC_TYPE "application/x-type-map"
  623. #define ASIS_MAGIC_TYPE "httpd/send-as-is"
  624. #define DIR_MAGIC_TYPE "httpd/unix-directory"
  625. #define STATUS_MAGIC_TYPE "application/x-httpd-status"
  626.  
  627. /*
  628.  * Define the HTML doctype strings centrally.
  629.  */
  630. #define DOCTYPE_HTML_2_0  "<!DOCTYPE HTML PUBLIC \"-//IETF//" \
  631.                           "DTD HTML 2.0//EN\">\n"
  632. #define DOCTYPE_HTML_3_2  "<!DOCTYPE HTML PUBLIC \"-//W3C//" \
  633.                           "DTD HTML 3.2 Final//EN\">\n"
  634. #define DOCTYPE_HTML_4_0S "<!DOCTYPE HTML PUBLIC \"-//W3C//" \
  635.                           "DTD HTML 4.0//EN\"\n" \
  636.                           "\"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
  637. #define DOCTYPE_HTML_4_0T "<!DOCTYPE HTML PUBLIC \"-//W3C//" \
  638.                           "DTD HTML 4.0 Transitional//EN\"\n" \
  639.                           "\"http://www.w3.org/TR/REC-html40/loose.dtd\">\n"
  640. #define DOCTYPE_HTML_4_0F "<!DOCTYPE HTML PUBLIC \"-//W3C//" \
  641.                           "DTD HTML 4.0 Frameset//EN\"\n" \
  642.                           "\"http://www.w3.org/TR/REC-html40/frameset.dtd\">\n"
  643.  
  644. /* Just in case your linefeed isn't the one the other end is expecting. */
  645. #ifndef CHARSET_EBCDIC
  646. #define LF 10
  647. #define CR 13
  648. #define CRLF "\015\012"
  649. #define OS_ASC(c) (c)
  650. #else /* CHARSET_EBCDIC */
  651. #include "ebcdic.h"
  652. /* OSD_POSIX uses the EBCDIC charset. The transition ASCII->EBCDIC is done in
  653.  * the buff package (bread/bputs/bwrite), so everywhere else, we use
  654.  * "native EBCDIC" CR and NL characters. These are therefore defined as
  655.  * '\r' and '\n'.
  656.  * NB: this is not the whole truth - sometimes \015 and \012 are contained
  657.  * in literal (EBCDIC!) strings, so these are not converted but passed.
  658.  */
  659. #define CR '\r'
  660. #define LF '\n'
  661. #define CRLF "\r\n"
  662. #define OS_ASC(c) (os_toascii[c])
  663. #endif /* CHARSET_EBCDIC */
  664.  
  665. /* Possible values for request_rec.read_body (set by handling module):
  666.  *    REQUEST_NO_BODY          Send 413 error if message has any body
  667.  *    REQUEST_CHUNKED_ERROR    Send 411 error if body without Content-Length
  668.  *    REQUEST_CHUNKED_DECHUNK  If chunked, remove the chunks for me.
  669.  *    REQUEST_CHUNKED_PASS     Pass the chunks to me without removal.
  670.  */
  671. #define REQUEST_NO_BODY          0
  672. #define REQUEST_CHUNKED_ERROR    1
  673. #define REQUEST_CHUNKED_DECHUNK  2
  674. #define REQUEST_CHUNKED_PASS     3
  675.  
  676. /* Things which may vary per file-lookup WITHIN a request ---
  677.  * e.g., state of MIME config.  Basically, the name of an object, info
  678.  * about the object, and any other info we may ahve which may need to
  679.  * change as we go poking around looking for it (e.g., overridden by
  680.  * .htaccess files).
  681.  *
  682.  * Note how the default state of almost all these things is properly
  683.  * zero, so that allocating it with pcalloc does the right thing without
  684.  * a whole lot of hairy initialization... so long as we are willing to
  685.  * make the (fairly) portable assumption that the bit pattern of a NULL
  686.  * pointer is, in fact, zero.
  687.  */
  688.  
  689. /* This represents the result of calling htaccess; these are cached for
  690.  * each request.
  691.  */
  692. struct htaccess_result {
  693.     char *dir;            /* the directory to which this applies */
  694.     int override;        /* the overrides allowed for the .htaccess file */
  695.     void *htaccess;        /* the configuration directives */
  696. /* the next one, or NULL if no more; N.B. never change this */
  697.     const struct htaccess_result *next;
  698. };
  699.  
  700. typedef struct conn_rec conn_rec;
  701. typedef struct server_rec server_rec;
  702. typedef struct request_rec request_rec;
  703. typedef struct listen_rec listen_rec;
  704.  
  705. #include "util_uri.h"
  706.  
  707. enum proxyreqtype {
  708.     NOT_PROXY=0,
  709.     STD_PROXY,
  710.     PROXY_PASS
  711. };
  712.  
  713. struct request_rec {
  714.  
  715.     ap_pool *pool;
  716.     conn_rec *connection;
  717.     server_rec *server;
  718.  
  719.     request_rec *next;        /* If we wind up getting redirected,
  720.                  * pointer to the request we redirected to.
  721.                  */
  722.     request_rec *prev;        /* If this is an internal redirect,
  723.                  * pointer to where we redirected *from*.
  724.                  */
  725.  
  726.     request_rec *main;        /* If this is a sub_request (see request.h) 
  727.                  * pointer back to the main request.
  728.                  */
  729.  
  730.     /* Info about the request itself... we begin with stuff that only
  731.      * protocol.c should ever touch...
  732.      */
  733.  
  734.     char *the_request;        /* First line of request, so we can log it */
  735.     int assbackwards;        /* HTTP/0.9, "simple" request */
  736.     enum proxyreqtype proxyreq;/* A proxy request (calculated during
  737.                  * post_read_request or translate_name) */
  738.     int header_only;        /* HEAD request, as opposed to GET */
  739.     char *protocol;        /* Protocol, as given to us, or HTTP/0.9 */
  740.     int proto_num;        /* Number version of protocol; 1.1 = 1001 */
  741.     const char *hostname;    /* Host, as set by full URI or Host: */
  742.  
  743.     time_t request_time;    /* When the request started */
  744.  
  745.     const char *status_line;    /* Status line, if set by script */
  746.     int status;            /* In any case */
  747.  
  748.     /* Request method, two ways; also, protocol, etc..  Outside of protocol.c,
  749.      * look, but don't touch.
  750.      */
  751.  
  752.     const char *method;        /* GET, HEAD, POST, etc. */
  753.     int method_number;        /* M_GET, M_POST, etc. */
  754.  
  755.     /*
  756.     allowed is a bitvector of the allowed methods.
  757.  
  758.     A handler must ensure that the request method is one that
  759.     it is capable of handling.  Generally modules should DECLINE
  760.     any request methods they do not handle.  Prior to aborting the
  761.     handler like this the handler should set r->allowed to the list
  762.     of methods that it is willing to handle.  This bitvector is used
  763.     to construct the "Allow:" header required for OPTIONS requests,
  764.     and METHOD_NOT_ALLOWED and NOT_IMPLEMENTED status codes.
  765.  
  766.     Since the default_handler deals with OPTIONS, all modules can
  767.     usually decline to deal with OPTIONS.  TRACE is always allowed,
  768.     modules don't need to set it explicitly.
  769.  
  770.     Since the default_handler will always handle a GET, a
  771.     module which does *not* implement GET should probably return
  772.     METHOD_NOT_ALLOWED.  Unfortunately this means that a Script GET
  773.     handler can't be installed by mod_actions.
  774.     */
  775.     int allowed;        /* Allowed methods - for 405, OPTIONS, etc */
  776.  
  777.     int sent_bodyct;        /* byte count in stream is for body */
  778.     long bytes_sent;        /* body byte count, for easy access */
  779.     time_t mtime;        /* Time the resource was last modified */
  780.  
  781.     /* HTTP/1.1 connection-level features */
  782.  
  783.     int chunked;        /* sending chunked transfer-coding */
  784.     int byterange;        /* number of byte ranges */
  785.     char *boundary;        /* multipart/byteranges boundary */
  786.     const char *range;        /* The Range: header */
  787.     long clength;        /* The "real" content length */
  788.  
  789.     long remaining;        /* bytes left to read */
  790.     long read_length;        /* bytes that have been read */
  791.     int read_body;        /* how the request body should be read */
  792.     int read_chunked;        /* reading chunked transfer-coding */
  793.     unsigned expecting_100;    /* is client waiting for a 100 response? */
  794.  
  795.     /* MIME header environments, in and out.  Also, an array containing
  796.      * environment variables to be passed to subprocesses, so people can
  797.      * write modules to add to that environment.
  798.      *
  799.      * The difference between headers_out and err_headers_out is that the
  800.      * latter are printed even on error, and persist across internal redirects
  801.      * (so the headers printed for ErrorDocument handlers will have them).
  802.      *
  803.      * The 'notes' table is for notes from one module to another, with no
  804.      * other set purpose in mind...
  805.      */
  806.  
  807.     table *headers_in;
  808.     table *headers_out;
  809.     table *err_headers_out;
  810.     table *subprocess_env;
  811.     table *notes;
  812.  
  813.     /* content_type, handler, content_encoding, content_language, and all
  814.      * content_languages MUST be lowercased strings.  They may be pointers
  815.      * to static strings; they should not be modified in place.
  816.      */
  817.     const char *content_type;    /* Break these out --- we dispatch on 'em */
  818.     const char *handler;    /* What we *really* dispatch on           */
  819.  
  820.     const char *content_encoding;
  821.     const char *content_language;    /* for back-compat. only -- do not use */
  822.     array_header *content_languages;    /* array of (char*) */
  823.  
  824.     char *vlist_validator;      /* variant list validator (if negotiated) */
  825.  
  826.     int no_cache;
  827.     int no_local_copy;
  828.  
  829.     /* What object is being requested (either directly, or via include
  830.      * or content-negotiation mapping).
  831.      */
  832.  
  833.     char *unparsed_uri;        /* the uri without any parsing performed */
  834.     char *uri;            /* the path portion of the URI */
  835.     char *filename;
  836.     char *path_info;
  837.     char *args;            /* QUERY_ARGS, if any */
  838.     struct stat finfo;        /* ST_MODE set to zero if no such file */
  839.     uri_components parsed_uri;    /* components of uri, dismantled */
  840.  
  841.     /* Various other config info which may change with .htaccess files
  842.      * These are config vectors, with one void* pointer for each module
  843.      * (the thing pointed to being the module's business).
  844.      */
  845.  
  846.     void *per_dir_config;    /* Options set in config files, etc. */
  847.     void *request_config;    /* Notes on *this* request */
  848.  
  849. /*
  850.  * a linked list of the configuration directives in the .htaccess files
  851.  * accessed by this request.
  852.  * N.B. always add to the head of the list, _never_ to the end.
  853.  * that way, a sub request's list can (temporarily) point to a parent's list
  854.  */
  855.     const struct htaccess_result *htaccess;
  856.  
  857.     /* On systems with case insensitive file systems (Windows, OS/2, etc.), 
  858.      * r->filename is case canonicalized (folded to either lower or upper 
  859.      * case, depending on the specific system) to accomodate file access
  860.      * checking. case_preserved_filename is the same as r->filename 
  861.      * except case is preserved. There is at least one instance where Apache 
  862.      * needs access to the case preserved filename: Java class files published 
  863.      * with WebDAV need to preserve filename case to make the Java compiler 
  864.      * happy.
  865.      */
  866.     char *case_preserved_filename;
  867.  
  868. /* Things placed at the end of the record to avoid breaking binary
  869.  * compatibility.  It would be nice to remember to reorder the entire
  870.  * record to improve 64bit alignment the next time we need to break
  871.  * binary compatibility for some other reason.
  872.  */
  873.  
  874. #ifdef EAPI
  875.     ap_ctx *ctx;
  876. #endif /* EAPI */
  877. };
  878.  
  879.  
  880. /* Things which are per connection
  881.  */
  882.  
  883. struct conn_rec {
  884.  
  885.     ap_pool *pool;
  886.     server_rec *server;
  887.     server_rec *base_server;    /* Physical vhost this conn come in on */
  888.     void *vhost_lookup_data;    /* used by http_vhost.c */
  889.  
  890.     /* Information about the connection itself */
  891.  
  892.     int child_num;        /* The number of the child handling conn_rec */
  893.     BUFF *client;        /* Connection to the guy */
  894.  
  895.     /* Who is the client? */
  896.  
  897.     struct sockaddr_in local_addr;    /* local address */
  898.     struct sockaddr_in remote_addr;    /* remote address */
  899.     char *remote_ip;        /* Client's IP address */
  900.     char *remote_host;        /* Client's DNS name, if known.
  901.                  * NULL if DNS hasn't been checked,
  902.                  * "" if it has and no address was found.
  903.                  * N.B. Only access this though
  904.                  * get_remote_host() */
  905.     char *remote_logname;    /* Only ever set if doing rfc1413 lookups.
  906.                  * N.B. Only access this through
  907.                  * get_remote_logname() */
  908.     char *user;            /* If an authentication check was made,
  909.                  * this gets set to the user name.  We assume
  910.                  * that there's only one user per connection(!)
  911.                  */
  912.     char *ap_auth_type;        /* Ditto. */
  913.  
  914.     unsigned aborted:1;        /* Are we still talking? */
  915.     signed int keepalive:2;    /* Are we using HTTP Keep-Alive?
  916.                  * -1 fatal error, 0 undecided, 1 yes */
  917.     unsigned keptalive:1;    /* Did we use HTTP Keep-Alive? */
  918.     signed int double_reverse:2;/* have we done double-reverse DNS?
  919.                  * -1 yes/failure, 0 not yet, 1 yes/success */
  920.     int keepalives;        /* How many times have we used it? */
  921.     char *local_ip;        /* server IP address */
  922.     char *local_host;        /* used for ap_get_server_name when
  923.                  * UseCanonicalName is set to DNS
  924.                  * (ignores setting of HostnameLookups) */
  925. #ifdef EAPI
  926.     ap_ctx *ctx;
  927. #endif /* EAPI */
  928. };
  929.  
  930. /* Per-vhost config... */
  931.  
  932. /* The address 255.255.255.255, when used as a virtualhost address,
  933.  * will become the "default" server when the ip doesn't match other vhosts.
  934.  */
  935. #define DEFAULT_VHOST_ADDR 0xfffffffful
  936.  
  937. typedef struct server_addr_rec server_addr_rec;
  938. struct server_addr_rec {
  939.     server_addr_rec *next;
  940.     struct in_addr host_addr;    /* The bound address, for this server */
  941.     unsigned short host_port;    /* The bound port, for this server */
  942.     char *virthost;        /* The name given in <VirtualHost> */
  943. };
  944.  
  945. struct server_rec {
  946.  
  947.     server_rec *next;
  948.  
  949.     /* description of where the definition came from */
  950.     const char *defn_name;
  951.     unsigned defn_line_number;
  952.  
  953.     /* Full locations of server config info */
  954.  
  955.     char *srm_confname;
  956.     char *access_confname;
  957.  
  958.     /* Contact information */
  959.  
  960.     char *server_admin;
  961.     char *server_hostname;
  962.     unsigned short port;    /* for redirects, etc. */
  963.  
  964.     /* Log files --- note that transfer log is now in the modules... */
  965.  
  966.     char *error_fname;
  967.     FILE *error_log;
  968.     int loglevel;
  969.  
  970.     /* Module-specific configuration for server, and defaults... */
  971.  
  972.     int is_virtual;        /* true if this is the virtual server */
  973.     void *module_config;    /* Config vector containing pointers to
  974.                  * modules' per-server config structures.
  975.                  */
  976.     void *lookup_defaults;    /* MIME type info, etc., before we start
  977.                  * checking per-directory info.
  978.                  */
  979.     /* Transaction handling */
  980.  
  981.     server_addr_rec *addrs;
  982.     int timeout;        /* Timeout, in seconds, before we give up */
  983.     int keep_alive_timeout;    /* Seconds we'll wait for another request */
  984.     int keep_alive_max;        /* Maximum requests per connection */
  985.     int keep_alive;        /* Use persistent connections? */
  986.     int send_buffer_size;    /* size of TCP send buffer (in bytes) */
  987.  
  988.     char *path;            /* Pathname for ServerPath */
  989.     int pathlen;        /* Length of path */
  990.  
  991.     array_header *names;    /* Normal names for ServerAlias servers */
  992.     array_header *wild_names;    /* Wildcarded names for ServerAlias servers */
  993.  
  994.     uid_t server_uid;        /* effective user id when calling exec wrapper */
  995.     gid_t server_gid;        /* effective group id when calling exec wrapper */
  996.  
  997.     int limit_req_line;      /* limit on size of the HTTP request line    */
  998.     int limit_req_fieldsize; /* limit on size of any request header field */
  999.     int limit_req_fields;    /* limit on number of request header fields  */
  1000.  
  1001. #ifdef EAPI
  1002.     ap_ctx *ctx;
  1003. #endif /* EAPI */
  1004. };
  1005.  
  1006. /* These are more like real hosts than virtual hosts */
  1007. struct listen_rec {
  1008.     listen_rec *next;
  1009.     struct sockaddr_in local_addr;    /* local IP address and port */
  1010.     int fd;
  1011.     int used;            /* Only used during restart */        
  1012. /* more stuff here, like which protocol is bound to the port */
  1013. };
  1014.  
  1015. /* Prototypes for utilities... util.c.
  1016.  */
  1017.  
  1018. extern void ap_util_init(void);
  1019.  
  1020. /* Time */
  1021. extern API_VAR_EXPORT const char ap_month_snames[12][4];
  1022. extern API_VAR_EXPORT const char ap_day_snames[7][4];
  1023.  
  1024. API_EXPORT(struct tm *) ap_get_gmtoff(int *tz);
  1025. API_EXPORT(char *) ap_get_time(void);
  1026. API_EXPORT(char *) ap_field_noparam(pool *p, const char *intype);
  1027. API_EXPORT(char *) ap_ht_time(pool *p, time_t t, const char *fmt, int gmt);
  1028. API_EXPORT(char *) ap_gm_timestr_822(pool *p, time_t t);
  1029.  
  1030. /* String handling. The *_nc variants allow you to use non-const char **s as
  1031.    arguments (unfortunately C won't automatically convert a char ** to a const
  1032.    char **) */
  1033.  
  1034. API_EXPORT(char *) ap_getword(pool *p, const char **line, char stop);
  1035. API_EXPORT(char *) ap_getword_nc(pool *p, char **line, char stop);
  1036. API_EXPORT(char *) ap_getword_white(pool *p, const char **line);
  1037. API_EXPORT(char *) ap_getword_white_nc(pool *p, char **line);
  1038. API_EXPORT(char *) ap_getword_nulls(pool *p, const char **line, char stop);
  1039. API_EXPORT(char *) ap_getword_nulls_nc(pool *p, char **line, char stop);
  1040. API_EXPORT(char *) ap_getword_conf(pool *p, const char **line);
  1041. API_EXPORT(char *) ap_getword_conf_nc(pool *p, char **line);
  1042.  
  1043. API_EXPORT(const char *) ap_size_list_item(const char **field, int *len);
  1044. API_EXPORT(char *) ap_get_list_item(pool *p, const char **field);
  1045. API_EXPORT(int) ap_find_list_item(pool *p, const char *line, const char *tok);
  1046.  
  1047. API_EXPORT(char *) ap_get_token(pool *p, const char **accept_line, int accept_white);
  1048. API_EXPORT(int) ap_find_token(pool *p, const char *line, const char *tok);
  1049. API_EXPORT(int) ap_find_last_token(pool *p, const char *line, const char *tok);
  1050.  
  1051. API_EXPORT(int) ap_is_url(const char *u);
  1052. API_EXPORT(int) ap_unescape_url(char *url);
  1053. API_EXPORT(void) ap_no2slash(char *name);
  1054. API_EXPORT(void) ap_getparents(char *name);
  1055. API_EXPORT(char *) ap_escape_path_segment(pool *p, const char *s);
  1056. API_EXPORT(char *) ap_os_escape_path(pool *p, const char *path, int partial);
  1057. #define ap_escape_uri(ppool,path) ap_os_escape_path(ppool,path,1)
  1058. API_EXPORT(char *) ap_escape_html(pool *p, const char *s);
  1059. API_EXPORT(char *) ap_construct_server(pool *p, const char *hostname,
  1060.                     unsigned port, const request_rec *r);
  1061. API_EXPORT(char *) ap_escape_shell_cmd(pool *p, const char *s);
  1062.  
  1063. API_EXPORT(int) ap_count_dirs(const char *path);
  1064. API_EXPORT(char *) ap_make_dirstr_prefix(char *d, const char *s, int n);
  1065. API_EXPORT(char *) ap_make_dirstr_parent(pool *p, const char *s);
  1066. /* deprecated.  The previous two routines are preferred. */
  1067. API_EXPORT(char *) ap_make_dirstr(pool *a, const char *s, int n);
  1068. API_EXPORT(char *) ap_make_full_path(pool *a, const char *dir, const char *f);
  1069.  
  1070. API_EXPORT(int) ap_is_matchexp(const char *str);
  1071. API_EXPORT(int) ap_strcmp_match(const char *str, const char *exp);
  1072. API_EXPORT(int) ap_strcasecmp_match(const char *str, const char *exp);
  1073. API_EXPORT(char *) ap_stripprefix(const char *bigstring, const char *prefix);
  1074. API_EXPORT(char *) ap_strcasestr(const char *s1, const char *s2);
  1075. API_EXPORT(char *) ap_pbase64decode(pool *p, const char *bufcoded);
  1076. API_EXPORT(char *) ap_pbase64encode(pool *p, char *string); 
  1077. API_EXPORT(char *) ap_uudecode(pool *p, const char *bufcoded);
  1078. API_EXPORT(char *) ap_uuencode(pool *p, char *string); 
  1079.  
  1080. #ifdef OS2
  1081. void os2pathname(char *path);
  1082. char *ap_double_quotes(pool *p, char *str);
  1083. #endif
  1084.  
  1085. API_EXPORT(int)    ap_regexec(const regex_t *preg, const char *string,
  1086.                               size_t nmatch, regmatch_t pmatch[], int eflags);
  1087. API_EXPORT(size_t) ap_regerror(int errcode, const regex_t *preg, 
  1088.                                char *errbuf, size_t errbuf_size);
  1089. API_EXPORT(char *) ap_pregsub(pool *p, const char *input, const char *source,
  1090.                               size_t nmatch, regmatch_t pmatch[]);
  1091.  
  1092. API_EXPORT(void) ap_content_type_tolower(char *);
  1093. API_EXPORT(void) ap_str_tolower(char *);
  1094. API_EXPORT(int) ap_ind(const char *, char);    /* Sigh... */
  1095. API_EXPORT(int) ap_rind(const char *, char);
  1096.  
  1097. API_EXPORT(char *) ap_escape_quotes (pool *p, const char *instring);
  1098. API_EXPORT(void) ap_remove_spaces(char *dest, char *src);
  1099.  
  1100. /* Common structure for reading of config files / passwd files etc. */
  1101. typedef struct {
  1102.     int (*getch) (void *param);    /* a getc()-like function */
  1103.     void *(*getstr) (void *buf, size_t bufsiz, void *param); /* a fgets()-like function */
  1104.     int (*close) (void *param);    /* a close hander function */
  1105.     void *param;        /* the argument passed to getch/getstr/close */
  1106.     const char *name;        /* the filename / description */
  1107.     unsigned line_number;    /* current line number, starting at 1 */
  1108. } configfile_t;
  1109.  
  1110. /* Open a configfile_t as FILE, return open configfile_t struct pointer */
  1111. API_EXPORT(configfile_t *) ap_pcfg_openfile(pool *p, const char *name);
  1112.  
  1113. /* Allocate a configfile_t handle with user defined functions and params */
  1114. API_EXPORT(configfile_t *) ap_pcfg_open_custom(pool *p, const char *descr,
  1115.     void *param,
  1116.     int(*getc_func)(void*),
  1117.     void *(*gets_func) (void *buf, size_t bufsiz, void *param),
  1118.     int(*close_func)(void *param));
  1119.  
  1120. /* Read one line from open configfile_t, strip LF, increase line number */
  1121. API_EXPORT(int) ap_cfg_getline(char *buf, size_t bufsize, configfile_t *cfp);
  1122.  
  1123. /* Read one char from open configfile_t, increase line number upon LF */
  1124. API_EXPORT(int) ap_cfg_getc(configfile_t *cfp);
  1125.  
  1126. /* Detach from open configfile_t, calling the close handler */
  1127. API_EXPORT(int) ap_cfg_closefile(configfile_t *cfp);
  1128.  
  1129. #ifdef NEED_STRERROR
  1130. char *strerror(int err);
  1131. #endif
  1132.  
  1133. /* Misc system hackery */
  1134.  
  1135. API_EXPORT(uid_t) ap_uname2id(const char *name);
  1136. API_EXPORT(gid_t) ap_gname2id(const char *name);
  1137. API_EXPORT(int) ap_is_directory(const char *name);
  1138. API_EXPORT(int) ap_is_rdirectory(const char *name);
  1139. API_EXPORT(int) ap_can_exec(const struct stat *);
  1140. API_EXPORT(void) ap_chdir_file(const char *file);
  1141.  
  1142. #ifndef HAVE_CANONICAL_FILENAME
  1143. /*
  1144.  *  We can't define these in os.h because of dependence on pool pointer.
  1145.  */
  1146. #define ap_os_canonical_filename(p,f)  (f)
  1147. #define ap_os_case_canonical_filename(p,f)  (f)
  1148. #define ap_os_systemcase_filename(p,f)  (f)
  1149. #else
  1150. API_EXPORT(char *) ap_os_canonical_filename(pool *p, const char *file);
  1151. #ifdef WIN32
  1152. API_EXPORT(char *) ap_os_case_canonical_filename(pool *pPool, const char *szFile);
  1153. API_EXPORT(char *) ap_os_systemcase_filename(pool *pPool, const char *szFile);
  1154. #elif defined(OS2)
  1155. API_EXPORT(char *) ap_os_case_canonical_filename(pool *pPool, const char *szFile);
  1156. API_EXPORT(char *) ap_os_systemcase_filename(pool *pPool, const char *szFile);
  1157. #else
  1158. /* XXX: This makes little sense for NETWARE ... NETWARE is case insensitive?
  1159.  */
  1160. #define ap_os_case_canonical_filename(p,f) ap_os_canonical_filename(p,f)
  1161. #define ap_os_systemcase_filename(p,f) ap_os_canonical_filename(p,f)
  1162. #endif
  1163. #endif
  1164.  
  1165. #ifdef _OSD_POSIX
  1166. extern const char *os_set_account(pool *p, const char *account);
  1167. extern int os_init_job_environment(server_rec *s, const char *user_name, int one_process);
  1168. #endif /* _OSD_POSIX */
  1169.  
  1170. char *ap_get_local_host(pool *);
  1171. unsigned long ap_get_virthost_addr(char *hostname, unsigned short *port);
  1172.  
  1173. extern API_VAR_EXPORT time_t ap_restart_time;
  1174.  
  1175. /*
  1176.  * Apache tries to keep all of its long term filehandles (such as log files,
  1177.  * and sockets) above this number.  This is to workaround problems in many
  1178.  * third party libraries that are compiled with a small FD_SETSIZE.  There
  1179.  * should be no reason to lower this, because it's only advisory.  If a file
  1180.  * can't be allocated above this number then it will remain in the "slack"
  1181.  * area.
  1182.  *
  1183.  * Only the low slack line is used by default.  If HIGH_SLACK_LINE is defined
  1184.  * then an attempt is also made to keep all non-FILE * files above the high
  1185.  * slack line.  This is to work around a Solaris C library limitation, where it
  1186.  * uses an unsigned char to store the file descriptor.
  1187.  */
  1188. #ifndef LOW_SLACK_LINE
  1189. #define LOW_SLACK_LINE    15
  1190. #endif
  1191. /* #define HIGH_SLACK_LINE      255 */
  1192.  
  1193. /*
  1194.  * The ap_slack() function takes a fd, and tries to move it above the indicated
  1195.  * line.  It returns an fd which may or may not have moved above the line, and
  1196.  * never fails.  If the high line was requested and it fails it will also try
  1197.  * the low line.
  1198.  */
  1199. #ifdef NO_SLACK
  1200. #define ap_slack(fd,line)   (fd)
  1201. #else
  1202. int ap_slack(int fd, int line);
  1203. #define AP_SLACK_LOW    1
  1204. #define AP_SLACK_HIGH    2
  1205. #endif
  1206.  
  1207. API_EXPORT(char *) ap_escape_quotes(pool *p, const char *instr);
  1208.  
  1209. /*
  1210.  * Redefine assert() to something more useful for an Apache...
  1211.  */
  1212. API_EXPORT(void) ap_log_assert(const char *szExp, const char *szFile, int nLine)
  1213.                 __attribute__((noreturn));
  1214. #define ap_assert(exp) ((exp) ? (void)0 : ap_log_assert(#exp,__FILE__,__LINE__))
  1215.  
  1216. /* The optimized timeout code only works if we're not MULTITHREAD and we're
  1217.  * also not using a scoreboard file
  1218.  */
  1219. #if !defined (MULTITHREAD) && \
  1220.     (defined (USE_MMAP_SCOREBOARD) || defined (USE_SHMGET_SCOREBOARD))
  1221. #define OPTIMIZE_TIMEOUTS
  1222. #endif
  1223.  
  1224. /* A set of flags which indicate places where the server should raise(SIGSTOP).
  1225.  * This is useful for debugging, because you can then attach to that process
  1226.  * with gdb and continue.  This is important in cases where one_process
  1227.  * debugging isn't possible.
  1228.  */
  1229. #define SIGSTOP_DETACH            1
  1230. #define SIGSTOP_MAKE_CHILD        2
  1231. #define SIGSTOP_SPAWN_CHILD        4
  1232. #define SIGSTOP_PIPED_LOG_SPAWN        8
  1233. #define SIGSTOP_CGI_CHILD        16
  1234.  
  1235. #ifdef DEBUG_SIGSTOP
  1236. extern int raise_sigstop_flags;
  1237. #define RAISE_SIGSTOP(x)    do { \
  1238.     if (raise_sigstop_flags & SIGSTOP_##x) raise(SIGSTOP);\
  1239.     } while (0)
  1240. #else
  1241. #define RAISE_SIGSTOP(x)
  1242. #endif
  1243.  
  1244. API_EXPORT(extern const char *) ap_psignature(const char *prefix, request_rec *r);
  1245.  
  1246. /* strtoul does not exist on sunos4. */
  1247. #ifdef strtoul
  1248. #undef strtoul
  1249. #endif
  1250. #define strtoul strtoul_is_not_a_portable_function_use_strtol_instead
  1251.  
  1252. #ifdef __cplusplus
  1253. }
  1254. #endif
  1255.  
  1256. #endif    /* !APACHE_HTTPD_H */
  1257.